$(function(){
   $("#txtstartTime").datebox("setValue", myformatter(new Date()));
   $("txtstartTime").datebox({  
       required:true,  
       onSelect: function(date){  
           $("#txtstartTime").val(date);  
       }  
   }); 
});
function zzqy(){
	var zzqy = getZzqyData();
	$.ajax({
		type: "post",
		dataType: "text",
		contentType: "application/json",
		data: zzqy,
		url: ctx + "/zzqy?action=0",
		success: function(v){
			if(v == "0"){
				layer.alert("组织失败");
			}else if(v == "2"){
				//layer.alert("亲美美，请登录后再提交");
			}else{
				/*$("#passwordShow").val('');
				$("#email").val('');
				window.location.href = "share/"+ v + ".html";*/
			}
		}
	});
}

function getZzqyData(){
	var title = $("#txttitle").val();
	if(title == ""){
		layer.alert("请输入组织标题", "9");
		return;
	}

	var startTime = $("#txtstartTime").datebox("getValue") + " 00:00:00";
	/*if(startTime == ""){
		layer.alert("请输入骑游开始时间", "9");
		return;
	}*/
	
	var days = $("#txtdays").val();
	if(days == ""){
		layer.alert("请输入骑游耗费天数", "9");
		return;
	}
	
	var content = um.getContent();
	if(content == ""){
		layer.alert("请输入组织内容", "9");
		return;
	}
	
	var obj = new Object();
	obj.title = title;	
	obj.content = content;
	obj.startTime = startTime;
	obj.days = days;
	var json = JSON.stringify(obj);
	
	return json;
}

function myformatter(date) {
	var y = date.getFullYear();
	var m = date.getMonth() + 1;
	var d = date.getDate();
	return y + '-' + (m < 10 ? ('0' + m) : m) + '-'
	+ (d < 10 ? ('0' + d) : d);
}
function myparser(s) {
	if (!s)
	return new Date();
	var ss = (s.split('-'));
	var y = parseInt(ss[0], 10);
	var m = parseInt(ss[1], 10);
	var d = parseInt(ss[2], 10);
	if (!isNaN(y) && !isNaN(m) && !isNaN(d)) {
		return new Date(y, m - 1, d);
	} else {
		return new Date();
	}
}
